package com.zhijian.warehouse.manage.entity.export;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.zhijian.util.BeanUtil;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * 库存管理 回显vo
 *
 * @author auto
 * @version 1.0
 * @date 2024-10-27 13:42:54
 */
@Data
public class StoreExport {

    @Excel(name = "序号", format = "isAddIndex")
    private Integer serial;

    @Excel(name = "商品名称")
    private String productName;

    @Excel(name = "产品编号", width = 20)
    private String productNumber;

    @Excel(name = "产品状态")
    private BigDecimal productCount;

    @Excel(name = "产品类型")
    private String categoryName;

    @Excel(name = "规格", width = 20)
    private String productModel;

    @Excel(name = "单位")
    private String unitName;

    @Excel(name = "仓库名称")
    private String warehouseName;

    @Excel(name = "库位名称")
    private String warehouseLocationName;

    @Excel(name = "当前库存")
    private String productCountInit;

    @Excel(name = "产品RFID", width = 30)
    private String productRfId;

    @Excel(name = "入库累积")
    private String waitStoreInCountInit;
    private BigDecimal waitStoreInCount;
    @Excel(name = "出库累积")
    private String waitStoreOutCountInit;
    private BigDecimal waitStoreOutCount;
    @Excel(name = "可用库存")
    private String storeUsableCountInit;

    private BigDecimal earlyCount;
    @Excel(name = "期初库存")
    private String earlyCountInit;

    @Excel(name = "期末库存")
    private String endCountInit;
    private BigDecimal endCount;

    private Integer productStatus;

    private BigDecimal storeUsableCount;
    private Integer unitFraction;

    public String getStoreUsableCountInit() {
        return initData(this.storeUsableCount);
    }

    public String getWaitStoreOutCountInit() {
        return initData(this.waitStoreOutCount);
    }

    public String getWaitStoreInCountInit() {
        return initData(this.waitStoreInCount);
    }

    public String getEndCountInit() {
        return initData(this.endCount);
    }

    public String getEarlyCountInit() {
        return initData(this.earlyCount);
    }

    public String getProductCountInit() {
        return initData(this.productCount);
    }
    //初始化 数据 如果不是空的则补全小数位
    public String initData(BigDecimal data) {
        if (data == null) {
            return BigDecimal.ZERO.toString();
        }
        if (BeanUtil.isEmpty(this.unitFraction))
            return data.toString();
        return data.setScale(this.unitFraction, RoundingMode.HALF_UP).toString();
    }
}
